-
-
Notifications
You must be signed in to change notification settings - Fork 145
refactor: #718 only drop TimestampSeries #1274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c81cd6e
to
d5e1089
Compare
d5e1089
to
41c7015
Compare
abf9147
to
cbbd372
Compare
@cmp0xff you have a number of PRs submitted while I was out on vacation for 2 weeks. Can you let me know which ones I should prioritize for review? |
Hi @Dr-Irv, I hope you had a nice vacation. My pull requests are categorised below. Each category is independent, but those in a higher position have a slightly higher priority in my opinion.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this. It's a lot of good work.
Main thing - if I'm going to merge this PR, it needs to be in a state where we don't need the followup PR.
Basic rule - we don't put ignore
in the tests unless we are testing that the stubs should not accept something that is invalid. You have places where you have added ignore
in the tests and I won't merge that in (unless we know it is a bug in the type checker)
tests/test_frame.py
Outdated
check(assert_type(s + summer, pd.Series), pd.Series) # type: ignore[assert-type] | ||
check(assert_type(s + df["y"], pd.Series), pd.Series) # type: ignore[assert-type] | ||
check(assert_type(summer + summer, pd.Series), pd.Series) # type: ignore[assert-type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't want to have ignore
in the tests. Fix the types to make this work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not there anymore.
Thank you very much for your quick and thorough reviews. I will be able to work on them next week. |
cbbd372
to
ed69ec5
Compare
b095af2
to
f1cf19f
Compare
3202bda
to
c4d657e
Compare
Hi @Dr-Irv @twoertwein, it is difficult to remove only Can we go back to the original plan, and remove both |
OK, you can try. But I think this may be something you can't fix due to how |
Hi @Dr-Irv, I continued working on the current #1274 anyway. Please let me know if you think we can proceed to merge it, or if we need to do better. In the latter case, I believe I have to remove both SummaryHighlights
To-dos
Orphaned comments#1274 (comment)
code removed, see #1274 (comment) #1274 (comment)
explained in #1274 (comment) #1274 (comment)
code removed, see #1274 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty close. There are 2 main issues reflected in the comments.
- I think the changes you made for
__sub__()
and possibly__mul__()
and related methods to handle int, float, etc., should be a separate PR, similar to what you did for_add__()
and__div__()
. If we can get that working, and then do this one, it will be easier to make sure all the tests are still working right. - I don't want to merge with any new
ignore
in the tests, because if someone pullsmain
, they will get something we know is broken. But I suggest a plan for handling that in the comments.
Thanks again for the great work on this.
check(x.astype(cast_arg), pd.Series, target_type) | ||
else: | ||
check(s.astype(cast_arg), TimestampSeries, target_type) | ||
check(s.astype(cast_arg), pd.Series, target_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these both be pd.Series[pd.Timestamp]
?
# Will be fixed after removing TimedeltaSeries, see Series.__sub__ in series.pyi | ||
check(assert_type(ss, pd.Series), pd.Series) # type: ignore[assert-type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm don't want to merge until we deal with this, because everything in main
should pass all the tests. But here is what I'd like to do. Once I'm OK with this PR, I won't merge it, and then the TimedeltaSeries
PR can merge into this branch where the line above should get fixed.
I could put this branch into the repo once approved so it becomes the new PR target of the next PR, and then once that is approved and merged, we do a new PR from that branch to main
# is invoked, but because of how Series.dt is hooked in and that we may not know the | ||
# type of the series, we don't know which kind of series was ...ed | ||
# in to the dt accessor | ||
|
||
_DTTimestampTimedeltaReturnType = TypeVar( | ||
"_DTTimestampTimedeltaReturnType", | ||
bound=Series | TimestampSeries | TimedeltaSeries | DatetimeIndex | TimedeltaIndex, | ||
"_DTTimestampTimedeltaReturnType", bound=Series | DatetimeIndex | TimedeltaIndex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear why TimedeltaSeries
is removed at this point. Or shouldn't it be bound=Series | Series[Timestamp] | TimedeltaSeries | DatetimeIndex | TimedeltaIndex
?
I know that Series
includes the other 2, but I'd like to keep this as close as possible to what was there before.
@overload | ||
def __sub__(self: Series[S1C], other: Series[Never]) -> Series: ... | ||
@overload | ||
def __sub__( | ||
self: Series[Timestamp], | ||
other: Timedelta | TimedeltaSeries | TimedeltaIndex | np.timedelta64, | ||
) -> TimestampSeries: ... | ||
self: Series[int], other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX] | ||
) -> Series[_T_COMPLEX]: ... | ||
@overload | ||
def __sub__(self: Series[int], other: np_ndarray_anyint) -> Series[int]: ... | ||
@overload | ||
def __sub__(self: Series[int], other: np_ndarray_float) -> Series[float]: ... | ||
@overload | ||
def __sub__(self: Series[int], other: np_ndarray_complex) -> Series[complex]: ... | ||
@overload | ||
def __sub__( | ||
self: Series[Timedelta], | ||
other: Timedelta | TimedeltaSeries | TimedeltaIndex | np.timedelta64, | ||
) -> TimedeltaSeries: ... | ||
self: Series[float], | ||
other: int | Sequence[int] | np_ndarray_anyint | np_ndarray_float | Series[int], | ||
) -> Series[float]: ... | ||
@overload | ||
def __sub__( | ||
self: Series[float], | ||
other: _T_COMPLEX | Sequence[_T_COMPLEX] | Series[_T_COMPLEX], | ||
) -> Series[_T_COMPLEX]: ... | ||
@overload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these changes for __sub__()
and __rsub__()
and sub()
should be in a separate PR like you did for add
and div
, with the tests like you did there.
@overload | ||
def __rtruediv__( # pyright: ignore[reportIncompatibleMethodOverride] | ||
self: Series[Timedelta], other: _nonseries_timedelta | Series[Timedelta] | ||
) -> Series[float]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can delete the first __rtruediv__()
declaration (or combine the 2) because it is returning the same result, and self
is already a subclass of Series[Timedelta]
. Not 100% sure of that
TimestampSeries
,TimedeltaSeries
, etc. can be removed #718assert_type()
to assert the type of any return value